package br.com.assessoriaesportiva.util;

import java.util.Map;

import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;

public class JsfUtil {


    public static void setSessionValue(String key, Object value){
        FacesContext.getCurrentInstance().getExternalContext()
                .getSessionMap().put(key, value);
    }
    
    public static Object getSessionValue(String key){
    	ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
    	if(context.getSessionMap().containsKey(key))
    		return context.getSessionMap().get(key);
    	return null;
    }

    public static void removeFromSession(String key){
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap()
                .remove(key);
    }

    public static String getParameter(String key){
        ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
        Map<String, String> parameters = context.getRequestParameterMap();
        if(parameters.containsKey(key)){
            return parameters.get(key);
        }
        return null;
    }
    
   
    
  
    

}
